<%@ include file="sites/ad_header.jsp" %>
<%@page import="my.db.DTO.ArticleDTO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="javax.sql.DataSource"%>
<%
	if(session.getAttribute("user") ==null){
		response.sendRedirect("LoadIndex.jsp");
	}
%>
<div class="r-body">
	<div class="page-title">
		<p>Article Report</p>
	</div>	
	
		<div class="frm-action">
				<%
				String error=request.getParameter("error");
				if(error !=null){
					out.println(error);
				}else{
					error="";
					out.println(error);
				}
				%>		
					<form action="./search_article.article" method="post" name="frm_action" >
					<table border="0" cellpadding="10">
						<tbody>
							<tr>
								<td>From Date</td>
								<td><input required="required" type="text" name="fromdate" class="fromdate" id="fromdate" onchange="search_article()"/></td>
								<td>To Date</td>
								<td><input type="text" required="required" name="todate" class="todate" id="todate" onchange="search_article()"/></td>
								<td width="100"><input type="submit" value="Search" name="cmdSerch" class="cmdSerch" id="search"/></td>
							</tr>
						</tbody>
					</table>
				   </form> 
				   
			<div class="grid-data" style="margin-top: 20px !important;">
					<table border="0" cellpadding="10" class="tb-data">
						<thead>
							<tr>
								<th>Article No</th>
								<th>Article Title</th>
								<th>Article Type</th>
								<th>Author Name</th>
								<th>Public date </th>
							</tr>
							
						</thead>
						<tbody>
						<%
							ArrayList<ArticleDTO> lst_ar=(ArrayList<ArticleDTO>)request.getAttribute("list_article");
							if(lst_ar !=null){
								for(int i=0;i<lst_ar.size();i++){
									ArticleDTO dto=lst_ar.get(i);					
						%>
						<tr>
							<td class="td-center"><%=dto.getArticleNo() %></td>
							<td class="td-center"><%=dto.getArticleTitle()%></td>
							<td class="td-center"><%=dto.getArticleType().getTypeName()%></td>
							<td class="td-center"><%=dto.getAuthor().getAuthorName()%></td>
							<td class="td-center"><%=dto.getArticleDate()%></td>
						</tr>
						<% 
								}
							}
						%>
						</tbody>	
					</table>	
					<table border="0" cellpadding="10">
						<tbody>
							<tr>
								<td></td>
								<td></td>
								<td width="100"><input type="submit" value="Print" name="cmdPrint" class="cmdPrint"/></td>
								<td width="100"><input type="submit" value="Export" name="cmdExport" class="cmdExport"/></td>
							</tr>
						</tbody>
					</table>
				</div>	<!-- End Grid-data -->
				<div>
						
				</div>
	</div><!-- end form action -->
	
	<script type="text/javascript">
		$(function(){
			 $(".fromdate").datepicker({
					changeMonth: true,
					changeYear:true,
					dateFormat:'yy-mm-dd'
			 });
			 $(".todate").datepicker({
					changeMonth: true,
					changeYear:true,
					dateFormat:'yy-mm-dd'
			 });
		});
	</script>
</div><!-- end r-body -->
</body>
</html>